﻿using System;
using System.Diagnostics;

namespace StockModel
{
    [DebuggerDisplay("Value = {Value}, Quantity = {Quantity}")]
    [Serializable]
    public class Order : ICloneable
    {
        #region Attributes

        private decimal _value;

        #endregion

        #region Properties

        public decimal Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = Decimal.Parse(value.ToString("####0.####"));
            }
        } 

        public int Quantity { get; set; }

        #endregion

        #region Public Methods

        public Order(decimal value, int quantity)
        {
            this.Value = value;
            this.Quantity = quantity;
        }

        public override bool Equals(object obj)
        {
            Order other = obj as Order;
            return other != null && this.Value == other.Value && this.Quantity == other.Quantity;
        }

        public override int GetHashCode()
        {
            return string.Format("{0}-{1}", this.Value, this.Quantity).GetHashCode();
        }

		public object Clone()
		{
			return new Order(this.Value, this.Quantity);
		}

        #endregion
	}
}
